home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Development / Interfaces / QD3DSet.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-14  |  10.1 KB  |  320 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DSet.h                                                 **
  4.  **                                                                             **
  5.  **                                                                             **
  6.  **     Purpose:     Set types and routines                                     **
  7.  **                                                                             **
  8.  **                                                                             **
  9.  **                                                                             **
  10.  **     Copyright (C) 1992-1995 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                             **
  12.  **                                                                             **
  13.  *****************************************************************************/
  14. #ifndef QD3DSet_h
  15. #define QD3DSet_h
  16.  
  17. #ifndef QD3D_h
  18. #include <QD3D.h>
  19. #endif  /*  QD3D_h  */
  20.  
  21. #if PRAGMA_ONCE
  22.     #pragma once
  23. #endif
  24.  
  25. #if defined(__MWERKS__)
  26.     #pragma enumsalwaysint on
  27.     #pragma align_array_members off
  28.     #pragma options align=native
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif    /* __cplusplus */
  34.  
  35.  
  36. /******************************************************************************
  37.  **                                                                             **
  38.  **                                Set Types                                     **
  39.  **                                                                             **
  40.  *****************************************************************************/
  41.  
  42. typedef long                    TQ3ElementType;
  43.  
  44. #define kQ3ElementTypeNone        0
  45. #define kQ3ElementTypeUnknown    32
  46.  
  47. /* 
  48.  *    kQ3ElementTypeUnknown is an TQ3Object. 
  49.  *    
  50.  *        Do Q3Set_Add(s, ..., &obj) or Q3Set_Get(s, ..., &obj);
  51.  *        
  52.  *        Note that the object is always referenced when copying around. 
  53.  *        
  54.  *        Generally, it is an Unknown object, a Group of Unknown objects, or a 
  55.  *        group of other "objects" which have been found in the metafile and
  56.  *        have no attachment method to their parent. Be prepared to handle
  57.  *        any or all of these cases if you actually access the set on a shape.
  58.  */
  59.  
  60. /******************************************************************************
  61.  **                                                                             **
  62.  **                                Set Routines                                 **
  63.  **                                                                             **
  64.  *****************************************************************************/
  65.  
  66. QD3D_EXPORT TQ3SetObject Q3Set_New(
  67.     void);
  68.  
  69. QD3D_EXPORT TQ3ObjectType Q3Set_GetType(
  70.     TQ3SetObject        set);
  71.  
  72. QD3D_EXPORT TQ3Status Q3Set_Add(
  73.     TQ3SetObject         set, 
  74.     TQ3ElementType        type,
  75.     const void             *data);
  76.  
  77. QD3D_EXPORT TQ3Status Q3Set_Get(
  78.     TQ3SetObject         set,
  79.     TQ3ElementType        type,
  80.     void                *data);
  81.  
  82. QD3D_EXPORT TQ3Boolean Q3Set_Contains(
  83.     TQ3SetObject         set,
  84.     TQ3ElementType        type);
  85.  
  86. QD3D_EXPORT TQ3Status Q3Set_Clear(
  87.     TQ3SetObject         set, 
  88.     TQ3ElementType        type);
  89.  
  90. QD3D_EXPORT TQ3Status Q3Set_Empty(
  91.     TQ3SetObject         target);
  92.  
  93. /*
  94.  *  Iterating through all elements in a set
  95.  *
  96.  *  Pass in kQ3ElementTypeNone to get first type
  97.  *  kQ3ElementTypeNone is returned when end of list is reached
  98.  */
  99. QD3D_EXPORT TQ3Status Q3Set_GetNextElementType(
  100.     TQ3SetObject         set,
  101.     TQ3ElementType        *type);        
  102.  
  103.  
  104. /******************************************************************************
  105.  **                                                                             **
  106.  **                                Attribute Types                                 **
  107.  **                                                                             **
  108.  *****************************************************************************/
  109.  
  110. /* 
  111.  *    For the data types listed below, pass in a pointer to it in the _Add 
  112.  *    and _Get calls.
  113.  *
  114.  *    For surface shader attributes, reference counts are incremented on 
  115.  *    the _Add and _Get 
  116.  */
  117.  
  118. typedef enum TQ3AttributeTypes {                /* Data Type                */
  119.     kQ3AttributeTypeNone                =  0,    /* ---------                */
  120.     kQ3AttributeTypeSurfaceUV            =  1,    /* TQ3Param2D                */ 
  121.     kQ3AttributeTypeShadingUV            =  2,    /* TQ3Param2D                 */
  122.     kQ3AttributeTypeNormal                =  3,    /* TQ3Vector3D                 */
  123.     kQ3AttributeTypeAmbientCoefficient    =  4,    /* float                     */
  124.     kQ3AttributeTypeDiffuseColor        =  5,    /* TQ3ColorRGB                */
  125.     kQ3AttributeTypeSpecularColor        =  6,    /* TQ3ColorRGB                */
  126.     kQ3AttributeTypeSpecularControl        =  7,    /* float                    */
  127.     kQ3AttributeTypeTransparencyColor    =  8,    /* TQ3ColorRGB                */
  128.     kQ3AttributeTypeSurfaceTangent        =  9,    /* TQ3Tangent2D              */
  129.     kQ3AttributeTypeHighlightState        = 10,    /* TQ3Switch                 */
  130.     kQ3AttributeTypeSurfaceShader        = 11,    /* TQ3SurfaceShaderObject    */
  131.     kQ3AttributeTypeNumTypes
  132. } TQ3AttributeTypes;
  133.  
  134. typedef TQ3ElementType TQ3AttributeType;
  135.  
  136.  
  137. /******************************************************************************
  138.  **                                                                             **
  139.  **                                Attribute Drawing                             **
  140.  **                                                                             **
  141.  *****************************************************************************/
  142.  
  143. QD3D_EXPORT TQ3Status Q3Attribute_Submit(
  144.     TQ3AttributeType        attributeType,
  145.     const void                *data,
  146.     TQ3ViewObject            view);
  147.  
  148.  
  149. /******************************************************************************
  150.  **                                                                             **
  151.  **                            AttributeSet Routines                             **
  152.  **                                                                             **
  153.  *****************************************************************************/
  154.  
  155. QD3D_EXPORT TQ3AttributeSet Q3AttributeSet_New(
  156.     void);
  157.  
  158. QD3D_EXPORT TQ3Status Q3AttributeSet_Add(
  159.     TQ3AttributeSet         attributeSet, 
  160.     TQ3AttributeType        type,
  161.     const void                 *data);
  162.  
  163. QD3D_EXPORT TQ3Boolean Q3AttributeSet_Contains(
  164.     TQ3AttributeSet            attributeSet,
  165.     TQ3AttributeType        attributeType);
  166.  
  167. QD3D_EXPORT TQ3Status Q3AttributeSet_Get(
  168.     TQ3AttributeSet         attributeSet,
  169.     TQ3AttributeType        type,
  170.     void                    *data);
  171.  
  172. QD3D_EXPORT TQ3Status Q3AttributeSet_Clear(
  173.     TQ3AttributeSet         attributeSet,
  174.     TQ3AttributeType        type);
  175.  
  176. QD3D_EXPORT TQ3Status Q3AttributeSet_Empty(
  177.     TQ3AttributeSet         target);
  178.  
  179. /*
  180.  * Q3AttributeSet_GetNextAttributeType
  181.  *
  182.  * Pass in kQ3AttributeTypeNone to get first type
  183.  * kQ3AttributeTypeNone is returned when end of list is reached
  184.  */
  185. QD3D_EXPORT TQ3Status Q3AttributeSet_GetNextAttributeType(
  186.     TQ3AttributeSet         source,
  187.     TQ3AttributeType        *type);        
  188.  
  189. QD3D_EXPORT TQ3Status Q3AttributeSet_Submit(
  190.     TQ3AttributeSet            attributeSet, 
  191.     TQ3ViewObject            view);
  192.  
  193. /*
  194.  * Inherit from parent->child into result
  195.  *    Result attributes are:
  196.  *        all child attributes + all parent attributes NOT in the child
  197.  */
  198. QD3D_EXPORT TQ3Status Q3AttributeSet_Inherit(
  199.     TQ3AttributeSet            parent, 
  200.     TQ3AttributeSet            child, 
  201.     TQ3AttributeSet            result);
  202.  
  203.  
  204. /******************************************************************************
  205.  **                                                                             **
  206.  **                            Custom Element Registration                         **
  207.  **                                                                             **
  208.  *****************************************************************************/
  209.  
  210. /*
  211.  * Element Methods - 
  212.  *
  213.  *         When you create a custom element, you control what structures are 
  214.  *        passed around the API. For example, you may allow the Q3Set_Add call 
  215.  *        take one type of argument, store your element internally in some 
  216.  *        abstract data type, and have the Q3Set_Get call take a different 
  217.  *        argument.
  218.  *
  219.  *        For example:
  220.  *            
  221.  *        There are four calls which at some point will copy an element:
  222.  *
  223.  *        Q3Set_Add (copied from Application memory to QuickDraw3D memory)
  224.  *        Q3Set_Get (copied from QuickDraw3D memory to Application memory)
  225.  *        Q3Object_Duplicate (all elements are copied internally)
  226.  *        Q3AttributeSet_Inherit (all elements are copied internally)
  227.  *
  228.  *         Either CopyAdd or CopyReplace is called during the "_Add" call.
  229.  *            - CopyAdd is destructive and should assume "toElement" is garbage
  230.  *            - CopyReplace is replacing an existing element.
  231.  *
  232.  *         CopyGet is called during the "_Get" call.
  233.  *
  234.  *         CopyDuplicate is called to duplicate an element's internal structure.
  235.  *
  236.  * Attributes Methods - 
  237.  *
  238.  *        For copying data while Inheriting. Element methods are used
  239.  *        at all other times.
  240.  *    
  241.  *         CopyInherit is called to duplicate an element's internal structure 
  242.  *            during inheritance. You should make this as fast as possible.
  243.  *            (for example, if your custom element contains objects, you
  244.  *             should do a Q3Shared_GetReference instead of a Q3Object_Duplicate)
  245.  *            
  246.  *        The ElementDelete method will be called for all of your elements copied 
  247.  *        around via CopyAdd, CopyReplace, CopyDuplicate, and CopyInherit.
  248.  *        If CopyGet allocates any memory in it's destination, it is up to the app 
  249.  *        to delete it on its side.
  250.  */
  251.  
  252. #define kQ3MethodTypeElementCopyAdd            Q3_METHOD_TYPE('e','c','p','a')
  253. #define kQ3MethodTypeElementCopyReplace        Q3_METHOD_TYPE('e','c','p','r')
  254. #define kQ3MethodTypeElementCopyGet            Q3_METHOD_TYPE('e','c','p','g')
  255. #define kQ3MethodTypeElementCopyDuplicate    Q3_METHOD_TYPE('e','c','p','d')
  256. #define kQ3MethodTypeElementDelete            Q3_METHOD_TYPE('e','d','e','l')
  257.  
  258. typedef TQ3Status (*TQ3ElementCopyAddMethod)(    
  259.     const void            *fromAPIElement,            /* element from _Add API call */
  260.     void                *toInternalElement);        /* to new QD3D internal element */
  261.  
  262. typedef TQ3Status (*TQ3ElementCopyReplaceMethod)(
  263.     const void            *fromAPIElement,            /* element from _Add API call */
  264.     void                *ontoInternalElement);        /* replacing QD3D internal element */
  265.  
  266. typedef TQ3Status (*TQ3ElementCopyGetMethod)(
  267.     const void            *fromInternalElement,        /* from QD3D internal element */
  268.     void                *toAPIElement);                /* to _Get API call */
  269.  
  270. typedef TQ3Status (*TQ3ElementCopyDuplicateMethod)(
  271.     const void            *fromInternalElement,        /* from QD3D internal element */
  272.     void                *toInternalElement);        /* to new QD3D internal element */
  273.  
  274. typedef TQ3Status (*TQ3ElementDeleteMethod)(    
  275.     void                *internalElement);
  276.  
  277. QD3D_EXPORT TQ3ObjectClass Q3ElementClass_Register(
  278.      TQ3ElementType        elementType,
  279.     const char            *name,
  280.     unsigned long        sizeOfElement,
  281.     TQ3MetaHandler        metaHandler);
  282.  
  283. QD3D_EXPORT TQ3Status Q3ElementType_GetElementSize(
  284.      TQ3ElementType        elementType,
  285.     unsigned long        *sizeOfElement);
  286.  
  287.  
  288. /******************************************************************************
  289.  **                                                                             **
  290.  **                        Custom Attribute Registration                         **
  291.  **                                                                             **
  292.  *****************************************************************************/
  293.  
  294. #define kQ3MethodTypeAttributeInherit        Q3_METHOD_TYPE('i','n','h','t')
  295. #define kQ3MethodTypeAttributeCopyInherit    Q3_METHOD_TYPE('a','c','p','i')
  296.  
  297. typedef TQ3Boolean TQ3AttributeInheritMethod;    
  298. /* return kQ3True or kQ3False in your metahandler */
  299.  
  300. typedef TQ3Status (*TQ3AttributeCopyInheritMethod)(
  301.     const void            *fromInternalAttribute,        /* from QD3D internal element */
  302.     void                *toInternalAttribute);        /* to new QD3D internal element */
  303.  
  304. QD3D_EXPORT TQ3ObjectClass Q3AttributeClass_Register(
  305.     TQ3AttributeType    attributeType,
  306.     const char            *creatorName,
  307.     unsigned long        sizeOfElement,
  308.     TQ3MetaHandler        metaHandler);
  309.  
  310. #ifdef __cplusplus
  311. }
  312. #endif    /* __cplusplus */
  313.  
  314. #if defined(__MWERKS__)
  315. #pragma options align=reset
  316. #pragma enumsalwaysint reset
  317. #endif
  318.  
  319. #endif /*  QD3DSet_h */
  320.